﻿using AspectCore.DynamicProxy;
using System;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;

namespace Finbook.ConsoleApp.Interceptors
{
    public class CustomInterceptorAttribute
        : AbstractInterceptorAttribute
    {
        public override async Task Invoke(AspectContext context, AspectDelegate next)
        {
            try
            {
                Console.WriteLine("Call me before.");
                await next.Invoke(context);
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                throw ex;
            }
            finally
            {
                Console.WriteLine("Call me after.");
            }

        }
    }
}
